package com.qst.action.TestPersonnel;

import com.qst.BaseServlet;
import com.qst.RequestUtil;
import com.qst.WebUtil;
import com.qst.entity.Team;
import com.qst.entity.TestPersonnel;
import com.qst.service.TeamService;
import com.qst.service.TestPersonnelService;
import com.qst.service.impl.ServiceFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

//@WebServlet("/testPersonnel/select.action")
public class SelectServlet extends BaseServlet {
    private TeamService classTeamService = ServiceFactory
            .getService(TeamService.class);
    private TestPersonnelService testPersonnelService = ServiceFactory
            .getService(TestPersonnelService.class);

    @Override
    protected void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int teamId= RequestUtil.getInt(req, "teamId");
        String name=RequestUtil.getString(req, "stuname");
        String phone=RequestUtil.getString(req, "phone");

        List<TestPersonnel> testPersonnel=testPersonnelService.query(teamId,name,phone);
        req.setAttribute("testPersonnel", testPersonnel);
        List<Team> teamList = classTeamService.findAll();
        req.setAttribute("teamList", teamList);

        WebUtil.forward(req, resp, "/testPersonnel/list.jsp");
    }
}
